package com.afc.struts.bustle.product;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.afc.struts.Action;
import com.afc.struts.bustle.data.ProductDao;
import com.afc.struts.bustle.model.ProductDto;

public class ProductUpdateOkAction implements Action<ProductForm>
{
  @Override
  public String execute(ProductForm anActionForm, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletException
  {
    ProductDto product = new ProductDto(anActionForm.getType(), anActionForm.getProvider(), anActionForm.getName(), anActionForm.getPrice(), anActionForm.getDescription(), anActionForm.getCreationDate(), anActionForm.getLimitedDate(), anActionForm.getImage());
    product.setIdProduct(anActionForm.getId());
    ProductDao.getInstance().update(product);
    return "/pages/products.jsp";
  }
}
